//
//  UIButton+Extension.swift
//  Weibo
//
//  Created by apple on 15/12/21.
//  Copyright © 2015年 Leon. All rights reserved.
//

import UIKit


extension UIButton {
    
    convenience init(title: String,backImageName: String,fontSize: CGFloat,color: UIColor) {
        //需要调用本类的指定构造函数  实例化自己
        self.init()
        setBackgroundImage(UIImage(named: backImageName), forState: .Normal)
        setTitle(title, forState: .Normal)
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
        setTitleColor(color, forState: .Normal)
        sizeToFit()
    }
    
    
    convenience init(imageName: String,backImageName: String) {
        self.init()
        
        // () 自定义样式
        setImage(UIImage(named: imageName), forState: .Normal)
        setImage(UIImage(named: imageName + "_highlighted"), forState: .Highlighted)
        setBackgroundImage(UIImage(named: backImageName), forState: .Normal)
        setBackgroundImage(UIImage(named: backImageName + "_highlighted"), forState: .Highlighted)
        //更具背景视图 自动设置大小
        sizeToFit()
        
    }
}